<!doctype html>
<html lang="zh-CN">

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>联赛统计</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-siteapp"/>
  <link rel="icon" type="image/png" href="./src/ico.ico">
  <link rel="apple-touch-icon-precomposed" href="./src/ico.ico">
  <link rel="stylesheet" href="assets/css/amazeui.min.css"/>
  <link rel="stylesheet" href="assets/css/admin.css">
  <link rel="stylesheet" href="assets/css/app.css">
  <link rel="stylesheet" href="./css/bootstrap.min.css">
  <link rel="stylesheet" href="./css/footable.core.css">
  <link rel="stylesheet" href="./css/clock.css">
  <style>
    .table > tbody > tr > td,
    .table > tbody > tr > th,
    .table > tfoot > tr > td,
    .table > tfoot > tr > th,
    .table > thead > tr > td,
    .table > thead > tr > th {
      padding: 2px;
      vertical-align: middle;
      text-align: center;
    }

    * {
      transition-duration: 0.2s;
    }

    .demoItem {
      position: relative;
      width: 100px;
      height: 20px;
      margin: 10px 20px;
      border: 1px solid rgba(255, 255, 255, 0.5);
      display: flex;
      justify-content: center;
      align-items: center;
    }

    .animation1 .shape {
      display: inline-block;
      margin: 0 5px;
      width: 10px;
      height: 10px;
      opacity: 0.5;
    }

    .animation1 .shape-1 {
      background-color: #1875E5;
      animation: AnimationShape1 1.5s ease infinite;
    }

    .animation1 .shape-2 {
      background-color: #C5523F;
      animation: AnimationShape1 1.5s ease infinite 0.5s;
    }

    .animation1 .shape-3 {
      background-color: #499255;
      animation: AnimationShape1 1.5s ease infinite 0.8s;
    }

    .animation1 .shape-4 {
      background-color: #F2B736;
      animation: AnimationShape1 1.5s ease infinite 1s;
    }

    @keyframes AnimationShape1 {
      0% {
        transfrom: scale(1);
        opacity: 0.5;
      }

      50% {
        transform: scale(1.5);
        opacity: 1;
      }

      100% {
        transfrom: scale(0.5);
        opacity: 0.5;
      }
    }

    /* animation2 */
    .animation2 .con {
      width: 30px;
      height: 30px;
      position: relative;
    }

    .animation2 .shape {
      position: absolute;
      width: 10px;
      height: 10px;
      display: inline-block;
      border-radius: 50%;
      top: 40%;
    }

    .animation2 .shape-1 {
      background-color: #1875E5;
      animation: AnimationShape2 1s ease infinite;
    }

    .animation2 .shape-2 {

      left: 10px;
      background-color: #C5523F;
    }

    .animation2 .shape-3 {
      left: 20px;
      background-color: #499255;
    }

    .animation2 .shape-4 {
      background-color: #F2B736;
      left: 30px;
      animation: AnimationShape3 1s ease infinite;
    }

    @keyframes AnimationShape2 {
      0% {
        left: -15px;
        top: 5px;
      }

      25% {
        left: 0;
        top: 40%;
      }

      50% {
        left: 0;
        top: 40%;
      }

      75% {
        left: 0;
        top: 40%;
      }

      100% {
        left: -15px;
        top: 5px;
      }
    }

    @keyframes AnimationShape3 {
      0% {
        left: 30px;
        top: 40%;
      }

      25% {
        left: 30px;
        top: 40%;
      }

      50% {
        left: 45px;
        top: 5px;
      }

      75% {
        left: 30px;
        top: 40%;
      }

      100% {
        left: 30px;
        top: 40%;
      }
    }
  </style>
</head>

<body data-type="generalComponents" style="background: #e9ecf3;">


<header class="am-topbar am-topbar-inverse admin-header">
  <div class="am-topbar-brand">
    <a href="javascript:;" class="tpl-logo">
      <img src="./src/ico.ico" alt="" class="catImg">
    </a>
  </div>
  <div class="am-icon-list tpl-header-nav-hover-ico am-fl am-margin-right">

  </div>

  <button
      class="am-topbar-btn am-topbar-toggle am-btn am-btn-sm am-btn-success am-show-sm-only"
      data-am-collapse="{target: '#topbar-collapse'}"><span class="am-sr-only">导航切换</span>
    <span
        class="am-icon-bars"></span></button>

  <div class="am-collapse am-topbar-collapse" id="topbar-collapse">

    <ul class="am-nav am-nav-pills am-topbar-nav am-topbar-right admin-header-list tpl-header-list">
      <li class="am-dropdown" data-am-dropdown data-am-dropdown-toggle>
        <a class="am-dropdown-toggle tpl-header-list-link" href="javascript:;">
          <span class="am-icon-bell-o"></span> 提醒 <span
            class="am-badge tpl-badge-success am-round">0</span></span>
        </a>
        <!-- <ul class="am-dropdown-content tpl-dropdown-content">
                    <li class="tpl-dropdown-content-external">
                        <h3>你有 <span class="tpl-color-success">5</span> 条提醒</h3><a href="###">全部</a>
                    </li>
                    <li class="tpl-dropdown-list-bdbc"><a href="#" class="tpl-dropdown-list-fl"><span
                                class="am-icon-btn am-icon-plus tpl-dropdown-ico-btn-size tpl-badge-success"></span>
                            【预览模块】移动端 查看时 手机、电脑框隐藏。</a>
                        <span class="tpl-dropdown-list-fr">3小时前</span>
                    </li>
                    <li class="tpl-dropdown-list-bdbc"><a href="#" class="tpl-dropdown-list-fl"><span
                                class="am-icon-btn am-icon-check tpl-dropdown-ico-btn-size tpl-badge-danger"></span>
                            移动端，导航条下边距处理</a>
                        <span class="tpl-dropdown-list-fr">15分钟前</span>
                    </li>
                    <li class="tpl-dropdown-list-bdbc"><a href="#" class="tpl-dropdown-list-fl"><span
                                class="am-icon-btn am-icon-bell-o tpl-dropdown-ico-btn-size tpl-badge-warning"></span>
                            追加统计代码</a>
                        <span class="tpl-dropdown-list-fr">2天前</span>
                    </li>
                </ul> -->
      </li>
      <li class="am-dropdown" data-am-dropdown data-am-dropdown-toggle>
        <a class="am-dropdown-toggle tpl-header-list-link" href="javascript:;">
          <span class="am-icon-comment-o"></span> 消息 <span
            class="am-badge tpl-badge-danger am-round">0</span></span>
        </a>
        <!-- <ul class="am-dropdown-content tpl-dropdown-content">
                    <li class="tpl-dropdown-content-external">
                        <h3>你有 <span class="tpl-color-danger">9</span> 条新消息</h3><a href="###">全部</a>
                    </li>
                    <li>
                        <a href="#" class="tpl-dropdown-content-message">
                            <span class="tpl-dropdown-content-photo">
                                <img src="assets/img/user02.png" alt=""> </span>
                            <span class="tpl-dropdown-content-subject">
                                <span class="tpl-dropdown-content-from"> 小早苗 </span>
                                <span class="tpl-dropdown-content-time">10分钟前 </span>
                            </span>
                            <span class="tpl-dropdown-content-font"> Amaze UI 的诞生，依托于 GitHub 及其他技术社区上一些优秀的资源；Amaze
                                UI 的成长，则离不开用户的支持。 </span>
                        </a>
                        <a href="#" class="tpl-dropdown-content-message">
                            <span class="tpl-dropdown-content-photo">
                                <img src="assets/img/user03.png" alt=""> </span>
                            <span class="tpl-dropdown-content-subject">
                                <span class="tpl-dropdown-content-from"> Steam </span>
                                <span class="tpl-dropdown-content-time">18分钟前</span>
                            </span>
                            <span class="tpl-dropdown-content-font"> 为了能最准确的传达所描述的问题， 建议你在反馈时附上演示，方便我们理解。 </span>
                        </a>
                    </li>

                </ul> -->
      </li>
      <li class="am-dropdown" data-am-dropdown data-am-dropdown-toggle>
        <a class="am-dropdown-toggle tpl-header-list-link" href="javascript:;">
          <span class="am-icon-calendar"></span> 进度 <span
            class="am-badge tpl-badge-primary am-round">0</span></span>
        </a>
        <ul class="am-dropdown-content tpl-dropdown-content">
          <li class="tpl-dropdown-content-external">
            <h3>你有 <span class="tpl-color-primary">0</span> 个任务进度</h3><a
              href="###">全部</a>
          </li>
          <li>
            <a href="javascript:;" class="tpl-dropdown-content-progress">
                                <span class="task">
                                    <span class="desc">v1.2 </span>
                                    <span class="percent">45%</span>
                                </span>
              <span class="progress">
                                    <div
                                        class="am-progress tpl-progress am-progress-striped">
                                        <div
                                            class="am-progress-bar am-progress-bar-success"
                                            style="width:45%"></div>
                                    </div>
                                </span>
            </a>
          </li>
          <li>
            <a href="javascript:;" class="tpl-dropdown-content-progress">
                                <span class="task">
                                    <span class="desc">新闻内容页 </span>
                                    <span class="percent">30%</span>
                                </span>
              <span class="progress">
                                    <div
                                        class="am-progress tpl-progress am-progress-striped">
                                        <div
                                            class="am-progress-bar am-progress-bar-secondary"
                                            style="width:30%"></div>
                                    </div>
                                </span>
            </a>
          </li>
          <li>
            <a href="javascript:;" class="tpl-dropdown-content-progress">
                                <span class="task">
                                    <span class="desc">管理中心 </span>
                                    <span class="percent">60%</span>
                                </span>
              <span class="progress">
                                    <div
                                        class="am-progress tpl-progress am-progress-striped">
                                        <div
                                            class="am-progress-bar am-progress-bar-warning"
                                            style="width:60%"></div>
                                    </div>
                                </span>
            </a>
          </li>

        </ul>
      </li>

      <li class="am-dropdown" data-am-dropdown data-am-dropdown-toggle>
        <a class="am-dropdown-toggle tpl-header-list-link" href="javascript:;">
          <span class="tpl-header-list-user-nick">小早苗</span><span
            class="tpl-header-list-user-ico"> <img
            src="./src/ico.ico"></span>
        </a>
        <ul class="am-dropdown-content">
          <li><a href="#"><span class="am-icon-bell-o"></span> 资料</a></li>
          <li><a href="#"><span class="am-icon-cog"></span> 设置</a></li>
          <li><a href="#"><span class="am-icon-power-off"></span> 退出</a></li>
        </ul>
      </li>
      <li><a href="###" class="tpl-header-list-link"><span
          class="am-icon-sign-out tpl-header-list-ico-out-size"></span></a></li>
    </ul>
  </div>
</header>


<div class="tpl-page-container tpl-page-header-fixed">


  <div class="tpl-left-nav tpl-left-nav-hover">
    <div class="tpl-left-nav-title">
      列表
    </div>
    <div class="tpl-left-nav-list">
      <ul class="tpl-left-nav-menu">
        <li class="tpl-left-nav-item">
          <a href="index.html" class="nav-link">
            <i class="am-icon-home"></i>
            <span>首页</span>
          </a>
        </li>
        <li class="tpl-left-nav-item">
          <a href="peopleList.html" class="nav-link tpl-left-nav-link-list">
            <i class="am-icon-bar-chart"></i>
            <span>各部成员</span>
            <!-- <i class="tpl-left-nav-content tpl-badge-danger">
                        12
                    </i> -->
          </a>
        </li>

        <li class="tpl-left-nav-item">
          <a href="javascript:;" class="nav-link tpl-left-nav-link-list">
            <i class="am-icon-table"></i>
            <span>部落战</span>
            <i class="am-icon-angle-right tpl-left-nav-more-ico am-fr am-margin-right"></i>
          </a>
          <ul class="tpl-left-nav-sub-menu" style="display: none;">
            <li>
              <a href="currentwar.html">
                <i class="am-icon-angle-right"></i>
                <span>当前部落战情况</span>
                <i class="am-icon-star tpl-left-nav-content-ico am-fr am-margin-right"></i>
              </a>

              <a href="warlog.html">
                <i class="am-icon-angle-right"></i>
                <span>历史部落战统计</span>

              </a>
            </li>
          </ul>
        </li>

        <li class="tpl-left-nav-item">
          <a href="javascript:;" class="nav-link tpl-left-nav-link-list active">
            <i class="am-icon-wpforms"></i>
            <span>联赛</span>
            <i
                class="am-icon-angle-right tpl-left-nav-more-ico am-fr am-margin-right tpl-left-nav-more-ico-rotate"></i>
          </a>
          <ul class="tpl-left-nav-sub-menu" style="display: block;">
            <li>
              <a href="./leaguegroup.html">
                <i class="am-icon-angle-right"></i>
                <span>当前联赛情况</span>
                <i class="am-icon-star tpl-left-nav-content-ico am-fr am-margin-right"></i>
              </a>

              <a href="./leaguegroupLog.html" class="active">
                <i class="am-icon-angle-right"></i>
                <span>历史联赛统计</span>
              </a>
            </li>
          </ul>
        </li>

        <!-- <li class="tpl-left-nav-item">
            <a href="login.html" class="nav-link tpl-left-nav-link-list">
                <i class="am-icon-key"></i>
                <span>登录</span>

            </a>
        </li> -->
      </ul>
    </div>
  </div>


  <div class="tpl-content-wrapper">
    <div class="clock">
      <!-- 表盘 -->
      <div class="board">
        <div></div>
      </div>
      <div class="number"></div>
      <div class="pointers">
        <div class="h"></div>
        <div class="m"></div>
        <div class="s"></div>
      </div>
      <div class="dot"></div>
    </div>
    <div class="tpl-content-page-title">
      联赛汇总情况
    </div>
    <ol class="am-breadcrumb">
      <li><a href="#" class="am-icon-home">首页</a></li>
      <li><a href="#">联赛</a></li>
      <li class="am-active">联赛汇总情况</li>
    </ol>
    <div class="tpl-portlet-components">
      <div class="portlet-title">
        <div class="caption font-green bold">
          <span class="am-icon-code"></span> Bigcat-总部联赛组汇总情况
        </div>
        <div class="tpl-portlet-input tpl-fz-ml">
          <div class="portlet-input input-small input-inline">
            <div class="input-icon right">
              <select class="form-control myOptionWarTag"></select>
            </div>
          </div>


        </div>
      </div>

      <div class="tpl-block">
        <div class="wrapper wrapper-content animated fadeInRight m-t-none"
             style="height: auto;">
          <div class="row">
            <div class="col-sm-12">
              <div class="ibox float-e-margins">
                <table class="footable table table-stripped table-bordered table-hover"
                       data-page-size="50" data-filter="filter">
                  <thead>
                  <tr>
                    <th>初始排名</th>
                    <th>名称</th>
                    <th>初始星数</th>
                    <th>总场</th>
                    <th>同本</th>
                    <th>低于同本</th>
                    <th>一</th>
                    <th>二</th>
                    <th>三</th>
                    <th>四</th>
                    <th>五</th>
                    <th>14本2星80%次数</th>
                    <th>14本3星</th>
                    <th>平均总星</th>
                  </tr>
                  </thead>
                  <tbody class="myTable-warContent"></tbody>
                  <tfoot>
                  <tr>
                    <td colspan="16">
                      <ul class="pagination pull-right"></ul>
                    </td>
                  </tr>
                  </tfoot>
                </table>
              </div>
            </div>
          </div>
        </div>
      </div>

    </div>
    <div class="tpl-portlet-components">
      <div class="portlet-title">
        <div class="caption font-green bold">
          <span class="am-icon-code"></span> Bigcat Ⅱ-联赛组汇总情况
        </div>
        <div class="tpl-portlet-input tpl-fz-ml">
          <div class="portlet-input input-small input-inline">
            <div class="input-icon right">
              <select class="form-control myOptionWarTag2"></select>
            </div>
          </div>
        </div>


      </div>

      <div class="tpl-block">
        <div class="wrapper wrapper-content animated fadeInRight m-t-none"
             style="height: auto;">
          <div class="row">
            <div class="col-sm-12">
              <div class="ibox float-e-margins">
                <table class="footable table table-stripped table-bordered table-hover"
                       data-page-size="50" data-filter="filter">
                  <thead>
                  <tr>
                    <th>初始排名</th>
                    <th>名称</th>
                    <th>初始星数</th>
                    <th>总场</th>
                    <th>同本</th>
                    <th>低于同本</th>
                    <th>一</th>
                    <th>二</th>
                    <th>三</th>
                    <th>四</th>
                    <th>五</th>
                    <th>14本2星80%次数</th>
                    <th>14本3星</th>
                    <th>平均总星</th>
                  </tr>
                  </thead>
                  <tbody class="myTable-warContent2"></tbody>
                  <tfoot>
                  <tr>
                    <td colspan="16">
                      <ul class="pagination pull-right"></ul>
                    </td>
                  </tr>
                  </tfoot>
                </table>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="tpl-portlet-components">
      <div class="portlet-title">
        <div class="caption font-green bold">
          <span class="am-icon-code"></span> Bigcat Ⅲ-联赛组汇总情况
        </div>
        <div class="tpl-portlet-input tpl-fz-ml">
          <div class="portlet-input input-small input-inline">
            <div class="input-icon right">
              <select class="form-control myOptionWarTag3"></select>
            </div>
          </div>
        </div>
      </div>

      <div class="tpl-block">


        <div class="wrapper wrapper-content animated fadeInRight m-t-none"
             style="height: auto;">
          <div class="row">
            <div class="col-sm-12">
              <div class="ibox float-e-margins">
                <table class="footable table table-stripped table-bordered table-hover"
                       data-page-size="50" data-filter="filter">
                  <thead>
                  <tr>
                    <th>初始排名</th>
                    <th>名称</th>
                    <th>初始星数</th>
                    <th>总场</th>
                    <th>同本</th>
                    <th>低于同本</th>
                    <th>一</th>
                    <th>二</th>
                    <th>三</th>
                    <th>四</th>
                    <th>五</th>
                    <th>14本2星80%次数</th>
                    <th>14本3星</th>
                    <th>平均总星</th>
                  </tr>
                  </thead>
                  <tbody class="myTable-warContent3"></tbody>
                  <tfoot>
                  <tr>
                    <td colspan="16">
                      <ul class="pagination pull-right"></ul>
                    </td>
                  </tr>
                  </tfoot>
                </table>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="tpl-portlet-components">
      <div class="portlet-title">
        <div class="caption font-green bold">
          <span class="am-icon-code"></span> 树海之森-联赛组汇总情况
        </div>
        <div class="tpl-portlet-input tpl-fz-ml">
          <div class="portlet-input input-small input-inline">
            <div class="input-icon right">
              <select class="form-control myOptionWarTag4"></select>
            </div>
          </div>
        </div>


      </div>

      <div class="tpl-block">


        <div class="wrapper wrapper-content animated fadeInRight m-t-none"
             style="height: auto;">
          <div class="row">
            <div class="col-sm-12">
              <div class="ibox float-e-margins">
                <table class="footable table table-stripped table-bordered table-hover"
                       data-page-size="50" data-filter="filter">
                  <thead>
                  <tr>
                    <th>初始排名</th>
                    <th>名称</th>
                    <th>初始星数</th>
                    <th>总场</th>
                    <th>同本</th>
                    <th>低于同本</th>
                    <th>一</th>
                    <th>二</th>
                    <th>三</th>
                    <th>四</th>
                    <th>五</th>
                    <th>14本2星80%次数</th>
                    <th>14本3星</th>
                    <th>平均总星</th>
                  </tr>
                  </thead>
                  <tbody class="myTable-warContent4"></tbody>
                  <tfoot>
                  <tr>
                    <td colspan="16">
                      <ul class="pagination pull-right"></ul>
                    </td>
                  </tr>
                  </tfoot>
                </table>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>


<script src="./js/forRange.js"></script>
<script src="assets/js/amazeui.min.js"></script>
<script src="assets/js/app.js"></script>
<script src="./js/bootstrap.min.js"></script>
<script src="./js/key.js"></script>

<script>
  $( '.catImg' ).on( 'click', function () {
    $( '.tpl-content-wrapper' )
        .hasClass( 'tpl-content-wrapper-hover' ) ? $( '.tpl-content-wrapper' )
        .removeClass( 'tpl-content-wrapper-hover' ) + $( '.tpl-left-nav' )
        .css( { display: 'block' } ) : $( '.tpl-content-wrapper' )
        .addClass( 'tpl-content-wrapper-hover' ) + $( '.tpl-left-nav' )
        .css( { display: 'none' } );
  } )
</script>
<script>
  const myAllUrl = allUrl + '/league_group?tag=';//调用地址
  range( myAllUrl, $( '.myTable-warContent' )
      .eq( 0 ), $( '.warTime' ), $( '.myOptionWarTag' ), '8CRUGCRU' ); // 总部
  // range(myAllUrl, $('.myTable-warContent').eq(0), $('.warTime'), $('.myOptionWarTag'), '29UPJP202'); // 战斗部
  // range(myAllUrl, $('.myTable-warContent').eq(0), $('.warTime'), $('.myOptionWarTag'), '2PGLLLRQP');// 联赛部
  // range( myAllUrl, $( '.myTable-warContent' ).eq( 0 ), $( '.warTime' ), $( '.myOptionWarTag' ), '2L9QRURPC' );// 战斗猫
  range( myAllUrl, $( '.myTable-warContent2' )
      .eq( 0 ), $( '.warTime2' ), $( '.myOptionWarTag2' ), '28YOOP9V2' ); //二部
  range( myAllUrl, $( '.myTable-warContent3' )
      .eq( 0 ), $( '.warTime3' ), $( '.myOptionWarTag3' ), '28U9CQCQU' ); // 三部
  range( myAllUrl, $( '.myTable-warContent4' )
      .eq( 0 ), $( '.warTime4' ), $( '.myOptionWarTag4' ), '289J0JRJV' ); // 树海

  function range( myurl, TableWarContent, warTime, myOptionWarTag, clanTag ) {
    let warTagArr = [];//所有对战标签的数组[第几场,对战标签,数据]
    let ajaxCount = 0;//请求的数量，达到数量后才算全部完成
    let myTableWarContent = TableWarContent;//对战详情表
    getWarDataAjax( myurl + clanTag, getMessage );//第一次请求，进页面直接获取，拿到所有warTag
    function getMessage( datas ) {//获取联赛信息，拿到每场对战的标签，用于重新获取那场战斗
      // console.log( datas );
      let data = datas;
      console.log( data );
      myOptionWarTag.html( '<option>' + data.season + '</option>' );//显示第几赛季
      let rounds = data.rounds;//所有场次
      rounds.forEach( function ( ele, index ) {
        ele.warTags.forEach( function ( ele2, index2 ) {
          let warTag = ele2.split( '#' )[1];
          warTagArr.push( [ index, ele2, getAllWarData( warTag ) ] );
        } )
      } )
      console.log( warTagArr );
      setWarDataToMyTableWarContent( warTagArr );
    }

    let useData = '';

    function getAllWarData( warTag ) {//为了返回出获取的数据存入warTagArr
      getWarDataAjax( allUrl + '/get_league_war_data?tag=' + warTag, getAllWarDataAjax );
      return useData;
    }

    function getAllWarDataAjax( data ) {//把每条ajax获取的数据都赋值给useData
      useData = data;
    }

    function setWarDataToMyTableWarContent( arr ) {
      let peopleArr = [];//people生成的包含所有信息的数组
      let obj = {};//存储所有人员的进攻信息
      let listArr = [];//存储所有人员的列表展示信息
      let dataOpponentMembersList = {};
      arr.forEach( function ( ele, index ) {
        let data = ele[2];
        if ( ele[2].clan.name.indexOf( 'Bigcat' ) === -1 && ele[2].clan.name.indexOf( '树海之森' ) === -1 && ele[2].clan.name.indexOf( '战斗猫' ) === -1 ) {//筛选掉不要的部落信息
          if ( ele[2].opponent.name.indexOf( 'Bigcat' ) === -1 && ele[2].opponent.name.indexOf( '树海之森' ) === -1 && ele[2].opponent.name.indexOf( '战斗猫' ) === -1 ) {//筛选掉不要的部落信息
            return;
          }
        }
        console.log( data );
        let { clan, opponent } = data;
        // console.log( opponent );
        let dataClan = clan;
        let dataOpponent = opponent;
        opponent.name.indexOf( 'Bigcat' ) !== -1 || opponent.name.indexOf( '树海之森' ) !== -1 || opponent.name.indexOf( '战斗猫' ) !== -1 ? ( dataClan = opponent ) + ( dataOpponent = clan ) : 0;//如果是我方部落，就把它交换
        //console.log(dataClan.members);
        dataClan.members.forEach( function ( ele2, index2 ) {//每次战斗中每个成员的信息
          console.log( ele2 )
          !obj[ele2.name] ? obj[ele2.name] = [] : 0;  // 判断是否已有这个人
          if ( !ele2.attacks ) {
            obj[ele2.name].push( 0 );
          } else {
            obj[ele2.name].push( ele2.attacks[0] );
          }
          dataOpponentMembersList[ele2.tag] = ele2.townhallLevel;//把我方部落成员大本等级也填入
        } );
        dataOpponent.members.forEach( function ( ele, index ) {//获取7场战斗所有敌方的大本等级列表
          dataOpponentMembersList[ele.tag] = ele.townhallLevel;
        } )
      } )
      console.log( obj );
      for ( prop in obj ) {
        // if (prop == '丿浅唱じ☆小亮亮' || prop == 'Relax'){
        //     continue
        // }
        let people = {
          firstNum: '',//初始排名
          name: prop,//名称
          firstStar: obj[prop].reduce( function ( last, ele, index ) {//初始星数
            index === 1 ? last = last.stars : 0;//第一次时，避免last是对象
            index === 1 && last === undefined ? last = 0 : 0;//第一次时，避免last是空
            let stars = ele.stars;
            stars === undefined ? stars = 0 : 0;
            return last + stars;
          } ),
          allDestructionPercentage: obj[prop].reduce( function ( last, ele, index ) {//总摧毁率
            index === 1 ? last = last.destructionPercentage : 0;//第一次时，避免last是对象
            index === 1 && last === undefined ? last = 0 : 0;//第一次时，避免last是空
            let destructionPercentage = ele.destructionPercentage;
            destructionPercentage === undefined ? destructionPercentage = 0 : 0;
            return last + destructionPercentage;
          } ),
          allAttackNum: obj[prop].reduce( function ( last, ele, index ) {//总场
            index === 1 && last !== 0 ? last = 1 : 0;//第一次时判断last是不是有一次进攻了
            let num = 0;
            ele !== 0 ? num++ : 0;//如果有进攻，就加1
            return last + num;
          } ),
          leaveAsMine: obj[prop].reduce( function ( last, ele, index ) {//同本
            let theLast = last;
            index === 1 && theLast !== 0 && dataOpponentMembersList[theLast.attackerTag] === dataOpponentMembersList[theLast.defenderTag] ? last = 1 : 0;//第一次时判断last是不是有一次进攻了
            index === 1 && theLast !== 0 && dataOpponentMembersList[theLast.attackerTag] !== dataOpponentMembersList[theLast.defenderTag] ? last = 0 : 0;
            let num = 0;
            ele !== 0 && dataOpponentMembersList[ele.attackerTag] === dataOpponentMembersList[ele.defenderTag] ? num++ : 0;//如果有进攻，就加1
            console.log( num );
            return last + num;
          } ),
          leaveLowMine: '',//低于同本
          lalala: console.log( prop ),
          attack1: obj[prop][0] !== 0 && obj[prop][0] !== undefined ? dataOpponentMembersList[obj[prop][0].defenderTag] + '本' + obj[prop][0].stars + '星' + obj[prop][0].destructionPercentage + '%' : 0,
          attack2: obj[prop][1] !== 0 && obj[prop][1] !== undefined ? dataOpponentMembersList[obj[prop][1].defenderTag] + '本' + obj[prop][1].stars + '星' + obj[prop][1].destructionPercentage + '%' : 0,
          attack3: obj[prop][2] !== 0 && obj[prop][2] !== undefined ? dataOpponentMembersList[obj[prop][2].defenderTag] + '本' + obj[prop][2].stars + '星' + obj[prop][2].destructionPercentage + '%' : 0,
          attack4: obj[prop][3] !== 0 && obj[prop][3] !== undefined ? dataOpponentMembersList[obj[prop][3].defenderTag] + '本' + obj[prop][3].stars + '星' + obj[prop][3].destructionPercentage + '%' : 0,
          attack5: obj[prop][4] !== 0 && obj[prop][4] !== undefined ? dataOpponentMembersList[obj[prop][4].defenderTag] + '本' + obj[prop][4].stars + '星' + obj[prop][4].destructionPercentage + '%' : 0,
          //attack6: obj[prop][5] !== 0 && obj[prop][5] !== undefined ? dataOpponentMembersList[obj[prop][5].defenderTag] + '本' + obj[prop][5].stars + '星' + obj[prop][5].destructionPercentage + '%' : 0,
          //attack7: obj[prop][6] !== 0 && obj[prop][6] !== undefined ? dataOpponentMembersList[obj[prop][6].defenderTag] + '本' + obj[prop][6].stars + '星' + obj[prop][6].destructionPercentage + '%' : 0,
          attackEightyNum: '',//中13本2星80%次数
          attackThreeStarNum: '',//中12本3星次数
          aveStar: '',//平均总星
          destructionPercentage1: obj[prop][0] !== 0 && obj[prop][0] !== undefined ? obj[prop][0].destructionPercentage : 0,//每次的摧毁率
          destructionPercentage2: obj[prop][1] !== 0 && obj[prop][1] !== undefined ? obj[prop][1].destructionPercentage : 0,//每次的摧毁率
          destructionPercentage3: obj[prop][2] !== 0 && obj[prop][2] !== undefined ? obj[prop][2].destructionPercentage : 0,//每次的摧毁率
          destructionPercentage4: obj[prop][3] !== 0 && obj[prop][3] !== undefined ? obj[prop][3].destructionPercentage : 0,//每次的摧毁率
          destructionPercentage5: obj[prop][4] !== 0 && obj[prop][4] !== undefined ? obj[prop][4].destructionPercentage : 0,//每次的摧毁率
          //destructionPercentage6: obj[prop][5] !== 0 && obj[prop][5] !== undefined ? obj[prop][5].destructionPercentage : 0,//每次的摧毁率
          //destructionPercentage7: obj[prop][6] !== 0 && obj[prop][6] !== undefined ? obj[prop][6].destructionPercentage : 0//每次的摧毁率
        }
        listArr.push( people );//把所有对象传入需要的数组中
      }
      let newListArr = listArr.filter( function ( ele, index ) {//把没有打的人筛选掉
        return ele.allAttackNum !== 0;
      } )
      newListArr.sort( function ( a, b ) {
        return b['allDestructionPercentage'] - a['allDestructionPercentage']
      } );//按摧毁率排序
      newListArr.sort( function ( a, b ) {
        return b['firstStar'] - a['firstStar']
      } );//按星数排序
      newListArr.forEach( function ( ele, index ) {//增加初始排名
        ele.firstNum = index + 1;
      } )
      newListArr.forEach( function ( ele, index ) {//计算低于同本并填入
        ele.leaveLowMine = ele.allAttackNum - ele.leaveAsMine;
      } )
      console.log( newListArr )
      newListArr.forEach( function ( ele, index ) {
        let star = ele.firstStar;
        let attackEightyNum = 0;//中12本2星80%次数
        let attackThreeStarNum = 0;//中12本3星次数
        index <= 3 ? star++ : 0;//前三名加一星
        star -= ele.leaveLowMine;//打低本减星
        ele.attack1 !== 0 && ele.attack1.indexOf( '14本2星' ) !== -1 && ele.destructionPercentage1 >= 80 ? attackEightyNum++ : 0;
        ele.attack2 !== 0 && ele.attack2.indexOf( '14本2星' ) !== -1 && ele.destructionPercentage2 >= 80 ? attackEightyNum++ : 0;
        ele.attack3 !== 0 && ele.attack3.indexOf( '14本2星' ) !== -1 && ele.destructionPercentage3 >= 80 ? attackEightyNum++ : 0;
        ele.attack4 !== 0 && ele.attack4.indexOf( '14本2星' ) !== -1 && ele.destructionPercentage4 >= 80 ? attackEightyNum++ : 0;
        ele.attack5 !== 0 && ele.attack5.indexOf( '14本2星' ) !== -1 && ele.destructionPercentage5 >= 80 ? attackEightyNum++ : 0;
        //ele.attack6 !== 0 && ele.attack6.indexOf( '14本2星' ) !== -1 && ele.destructionPercentage6 >= 80 ? attackEightyNum++ : 0;
        //ele.attack7 !== 0 && ele.attack7.indexOf( '14本2星' ) !== -1 && ele.destructionPercentage7 >= 80 ? attackEightyNum++ : 0;
        ele.attack1 !== 0 && ele.attack1.indexOf( '14本3星' ) !== -1 ? attackThreeStarNum++ : 0;
        ele.attack2 !== 0 && ele.attack2.indexOf( '14本3星' ) !== -1 ? attackThreeStarNum++ : 0;
        ele.attack3 !== 0 && ele.attack3.indexOf( '14本3星' ) !== -1 ? attackThreeStarNum++ : 0;
        ele.attack4 !== 0 && ele.attack4.indexOf( '14本3星' ) !== -1 ? attackThreeStarNum++ : 0;
        ele.attack5 !== 0 && ele.attack5.indexOf( '14本3星' ) !== -1 ? attackThreeStarNum++ : 0;
        //ele.attack6 !== 0 && ele.attack6.indexOf( '14本3星' ) !== -1 ? attackThreeStarNum++ : 0;
        //ele.attack7 !== 0 && ele.attack7.indexOf( '14本3星' ) !== -1 ? attackThreeStarNum++ : 0;
        ele.attackEightyNum = attackEightyNum;
        ele.attackThreeStarNum = attackThreeStarNum;
        switch ( attackEightyNum ) {
          case 0:
            break;
          case 1:
            star = star + 1;
            break;
          case 2:
            star = star + 1;
            break;
          case 3:
            star = star + 2;
            break;
          case 4:
            star = star + 2;
            break;
          case 5:
            star = star + 3;
            break;
          // case 6:
          //   star = star + 3;
          //   break;
          // case 7:
          //   star = star + 3;
          //   break;
        }
        switch ( attackThreeStarNum ) {
          case 0:
            break;
          case 1:
            break;
          case 2:
            star = star + 1;
            break;
          case 3:
            star = star + 1;
            break;
          case 4:
            star = star + 2;
            break;
          case 5:
            star = star + 2;
            break;
          // case 6:
          //   star = star + 3;
          //   break;
          // case 7:
          //   star = star + 3;
          //   break;
        }
        ele.aveStar = ( star / ele.allAttackNum ).toFixed( 4 );//求平均总星
      } )
      newListArr.sort( function ( a, b ) {
        return b['aveStar'] - a['aveStar']
      } );//按平均总星排序
      newListArr.forEach( ( ele, index ) => {
        if ( ele.attack3 === 0 ) {
          newListArr.push( newListArr.splice( index, 1 )[0] );
        }
      } )
      console.log( newListArr );
      let str = '';
      newListArr.forEach( function ( ele, index ) {
        if ( index % 2 === 0 ) {//区分奇偶行
          str += '<tr class="gradeA footable-odd"><td>' + ele.firstNum + '</td><td>' + ele.name + '</td><td>' + ele.firstStar + '</td><td>' + ele.allAttackNum + '</td><td>' + ele.leaveAsMine + '</td><td>' + ele.leaveLowMine + '</td><td class="attacks1">' + ele.attack1 + '</td><td class="attacks1">' + ele.attack2 + '</td><td class="attacks1">' + ele.attack3 + '</td><td class="attacks1">' + ele.attack4 + '</td><td class="attacks1">' + ele.attack5 + '</td><td class="attacks1">' + ele.attack6 + '</td><td class="attacks1">' + ele.attack7 + '</td><td>' + ele.attackEightyNum + '</td><td>' + ele.attackThreeStarNum + '</td><td>' + ele.aveStar + '</td></tr>';
        } else {
          str += '<tr class="gradeA footable-even"><td>' + ele.firstNum + '</td><td>' + ele.name + '</td><td>' + ele.firstStar + '</td><td>' + ele.allAttackNum + '</td><td>' + ele.leaveAsMine + '</td><td>' + ele.leaveLowMine + '</td><td class="attacks1">' + ele.attack1 + '</td><td class="attacks1">' + ele.attack2 + '</td><td class="attacks1">' + ele.attack3 + '</td><td class="attacks1">' + ele.attack4 + '</td><td class="attacks1">' + ele.attack5 + '</td><td class="attacks1">' + ele.attack6 + '</td><td class="attacks1">' + ele.attack7 + '</td><td>' + ele.attackEightyNum + '</td><td>' + ele.attackThreeStarNum + '</td><td>' + ele.aveStar + '</td></tr>';
        }
      } )
      myTableWarContent.html( str );
      let arrAttacks = $( '.attacks1' );//选出所有进攻栏目的td
      for ( let i = 0; i < arrAttacks.length; i++ ) {//筛选出1星变红，3星变蓝
        let str = arrAttacks[i].innerHTML;
        if ( str !== '' && str !== 0 ) {
          let arr = str.split( '星' );
          let arr1 = arr[0].split( '本' );
          arr1[1].indexOf( '1' ) !== -1 || arr1[1].indexOf( '0' ) !== -1 ? $( arrAttacks[i] )
              .css( { backgroundColor: '#f40' } ) : 0;
          arr1[1].indexOf( '3' ) !== -1 ? $( arrAttacks[i] )
              .css( { backgroundColor: '#4489e8' } ).html( $( arrAttacks[i] )
                  .html() + '<i class="fa fa-thumbs-up" aria-hidden="true"></i>' ) : 0;
        }
      }
    }

    function getWarDataAjax( myurl, success ) {
      $.ajax( {
        url: myurl,
        type: 'GET',
        success: success,
        error: myerror,
        beforeSend: mybeforeSend,
        async: false
      } )
    }

    function myerror( e ) {
      console.log( e.status, e.statusText );//状态码和信息
      myTableWarContent.html( '失败，请尝试刷新..............' );
    }

    function mybeforeSend() {
      myTableWarContent.html( '<div class="demoItem animation2"><div class="con"><div class="shape shape-1"></div><div class="shape shape-2"></div><div class="shape shape-3"></div><div class="shape shape-4"></div></div></div>' );
    }

    function changeTime( time ) {//把获取的时间分割好，并转为东八区
      let str = time;
      let year = str.slice( 0, 4 );
      let mon = str.slice( 4, 6 );
      let data = str.slice( 6, 8 );
      let hour = parseInt( str.slice( 9, 11 ) ) + 8;
      let min = str.slice( 11, 13 );
      let sec = str.slice( 13, 15 );
      hour >= 24 ? hour -= 24 : 0;
      hour >= 24 && hour <= 9 ? hour = '0' + hour : 0;
      return year + '-' + mon + '-' + data + '_' + hour + ':' + min + ':' + sec;
    }
  }
</script>
<script src="./js/clock.js"></script>
</body>

</html>
